import 'package:enterprise_v6_app/app/components/custom_refresh.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/ext/widget_extension.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/education/teacher_power/lecturer_list_page_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/education/teacher_power/teacher_power_controller.dart';

///师资力量
class TeacherPowerView extends StatelessWidget {
  TeacherPowerView({super.key}){
    Get.lazyPut(TeacherPowerController.new);
  }
  @override
  Widget build(BuildContext context) {
    final TeacherPowerController controller = Get.find<TeacherPowerController>();
    return GetBuilder(
        init: controller,
        builder: (_) {
          return Scaffold(
            key: controller.riskRightScaffoldKey,
            body: Container(
              color: AppColors.bg_color_grey,
              padding: EdgeInsets.only(top: 12.w, right: 14.w, left: 14.w),
              child: Column(
                children: [
                  Expanded(
                      child: CustomEasyRefreshList<LecturerListPageEntity>(
                    key: controller.globalKey,
                    dataLoad: controller.listPage,
                    itemBuilder: (item, index) {
                      return _customWidget(item,controller);
                    },
                  )),
                ],
              ),
            ), // 右侧筛选栏
          );
        });
  }

  Widget _customWidget(LecturerListPageEntity item, TeacherPowerController controller) {
    return Container(
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(8.r),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Padding(
            padding: EdgeInsets.only(left: 14.w, right: 14.w, top: 14.w, bottom: 10.w),
            child: Row(
              children: [
                item.lecturerHead == null
                    ? SvgPicture.asset(AppImages.icon_train_teacher_bg)
                    : Container(
                        margin: EdgeInsets.only(top: 8.w, right: 8.w),
                        width: 50.w,
                        height: 50.w,
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(40.w),
                            color: Colors.white,
                            border: Border.all(
                              color: const Color(0xFFEFF2F6),
                              width: 1,
                            ),
                            image: DecorationImage(
                              image: NetworkImage('${Interface.fileUrl}${item.lecturerHead}'),
                              // image: NetworkImage('${item.lecturerHead}'),
                            )),
                      ).clickShowLarge(url: '${item.lecturerHead}'),
                AppGaps.hGap8,
                Expanded(
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Row(
                        children: [
                          Expanded(
                            child: Text(
                              '${item.lecturerName}',
                              style: TextStyle(
                                color: const Color(0xFF495061),
                                fontSize: 14.sp,
                                fontWeight: FontWeight.w400,
                              ),
                            ),
                          ),
                        ],
                      ),
                      AppGaps.vGap4,
                      Row(
                        children: [
                          SvgPicture.asset(AppImages.icon_train_like_),
                          AppGaps.hGap8,
                          Text(
                            '${item.likeNum ?? 0}',
                            style: TextStyle(
                              color: const Color(0xFFFC9900),
                              fontSize: 14.sp,
                              fontWeight: FontWeight.w400,
                            ),
                          ),
                          AppGaps.hGap8,
                          Container(
                            padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 1.w),
                            decoration: BoxDecoration(
                              color: const Color(0x1AFC9900),
                              borderRadius: BorderRadius.circular(10.r),
                            ),
                            child: Text(
                              item.lecturerType ?? '无',
                              style: TextStyle(
                                color: const Color(0xFFFD9826),
                                fontSize: 12.sp,
                                fontWeight: FontWeight.w400,
                              ),
                            ),
                          )
                        ],
                      ).clickOnce(() {
                        //点赞
                        controller.onClickTrainLikeTeacher(item.id);
                      }),
                    ],
                  ),
                ),
              ],
            ),
          ),
          Container(
            color: const Color(0xFFA5A9C8).withOpacity(0.2),
            height: 1.w,
          ),
          Padding(
            padding: EdgeInsets.only(left: 12.w, top: 10.w, right: 12.w, bottom: 14.w),
            child: Text(
              '${item.lecturerProfiles}',
              style: TextStyle(
                color: const Color(0xFF495061),
                fontWeight: FontWeight.w400,
                fontSize: 12.sp,
              ),
            ),
          )
        ],
      ),
    );
  }
}
